//
//  OrderformTableViewCell.m
//  Youhuiju
//
//  Created by liuovyue on 16/7/26.
//  Copyright © 2016年 yutenys. All rights reserved.
//

#import "OrderformTableViewCell.h"
#import "OrderformCollectionViewCell.h"
#import "ReceiveGoodsController.h"
#import "ReceiveGoodsController.h"

@interface OrderformTableViewCell()<UICollectionViewDelegate, UICollectionViewDataSource>
@property (nonatomic, strong)NSArray *arr;
@property (nonatomic, strong)NSArray *arrImage;
@property (strong, nonatomic) IBOutlet UIButton *buttonLookMore;
@property (strong, nonatomic) IBOutlet UILabel *buttonMyOrder;
@property (strong, nonatomic) IBOutlet UICollectionView *collectionOrderform;
@property (strong, nonatomic) IBOutlet UILabel *labelOrder;//我的订单

//订单标题
@property (strong, nonatomic) IBOutlet NSLayoutConstraint *orderImageLead;
@property (strong, nonatomic) IBOutlet NSLayoutConstraint *orderImageTop;
@property (strong, nonatomic) IBOutlet NSLayoutConstraint *orderImageWidth;
@property (strong, nonatomic) IBOutlet NSLayoutConstraint *Height;

//我的订单
@property (strong, nonatomic) IBOutlet NSLayoutConstraint *orderWidth;
@property (strong, nonatomic) IBOutlet NSLayoutConstraint *orderLead;
@property (strong, nonatomic) IBOutlet NSLayoutConstraint *orderTop;
@property (strong, nonatomic) IBOutlet NSLayoutConstraint *orderHeight;
@property (strong, nonatomic) IBOutlet NSLayoutConstraint *orderTrail;


//查看全部订单
@property (strong, nonatomic) IBOutlet NSLayoutConstraint *lookMoreLead;
@property (strong, nonatomic) IBOutlet NSLayoutConstraint *lookMoreBot;
@property (strong, nonatomic) IBOutlet NSLayoutConstraint *lookMoreTop;
@property (strong, nonatomic) IBOutlet NSLayoutConstraint *lookMoreTrail;
@property (strong, nonatomic) IBOutlet UIButton *buttonLookAl;

//collection
@property (strong, nonatomic) IBOutlet NSLayoutConstraint *collectionTop;
@property (strong, nonatomic) IBOutlet NSLayoutConstraint *collectionTrail;
@property (strong, nonatomic) IBOutlet NSLayoutConstraint *collectionBot;
@property (strong, nonatomic) IBOutlet NSLayoutConstraint *collectionLead;


@property (strong, nonatomic) IBOutlet NSLayoutConstraint *imageLookMorePicture;


@property (strong, nonatomic) IBOutlet NSLayoutConstraint *lookMore;



@end

@implementation OrderformTableViewCell



- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    
    
   
    self.lookMore.constant = 8*FitH;
    self.imageLookMorePicture.constant = 15*FitH;
    
    self.buttonLookMore.tintColor = [UIColor colorWithHexString:@"999999"];
    self.buttonLookMore.titleLabel.font = [UIFont systemFontOfSize:14*FitH];
    
    self.collectionOrderForm.scrollEnabled = NO;
    
    //self.buttonMyOrder.textColor = [UIColor colorWithHexString:@"333333"];
    
    
    
        self.arr = @[@"  待付款",@"  待发货",@"  待收货",@"  待评价",@"   退货"];
    
    self.arrImage = @[@"wallet",@"box-closed",@"truck",@"speech-bubble",@"returned-purchase"];

    //self.labelOrder.textColor = [UIColor colorWithHexString:@"666666"];
    self.labelOrder.font = [UIFont systemFontOfSize:17*FitH];
    
    _collectionOrderForm.delegate = self;
    _collectionOrderForm.dataSource = self;
    [self.collectionOrderForm registerNib:[UINib nibWithNibName:@"OrderformCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"Orderform"];
    
   
   
    
    
    //我的订单
    self.orderTop.constant = 8*FitH;
    
    self.orderTrail.constant = 187*FitW;
    self.buttonLookMore.titleLabel.font = [UIFont systemFontOfSize:17*FitW];
    
    
    //查看全部订单
    self.lookMoreBot.constant = 16*FitH;
//    self.lookMoreTop.constant =  16*FitH;
    self.lookMoreLead.constant = 187*FitW;
    self.buttonAll.titleLabel.font = [UIFont systemFontOfSize:12*FitW];
//self.lookMoreTrail.constant = 23*FitW;
    
    //collection
    self.collectionBot.constant = 0*FitH;
    self.collectionTop.constant = 36*FitH;
    self.collectionLead.constant = 0;
    self.collectionTrail.constant = 0*FitW;
    
    
    [self.buttonAll addTarget:self action:@selector(nextAction:) forControlEvents:UIControlEventTouchUpInside];
    
}

- (void)nextAction:(UIButton *)button {
    
    id object = [self nextResponder];
    while (![object isKindOfClass:[UIViewController class]]&&object != nil) {
        
        
        object = [object nextResponder];
        
    }
    UIViewController *vc = (UIViewController *)object;
    ReceiveGoodsController *goods = [[ReceiveGoodsController alloc]init];
    [vc.navigationController pushViewController:goods animated:YES];
    vc.tabBarController.tabBar.hidden = YES;
    
    
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    
    return self.arrImage.count;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    
    OrderformCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Orderform" forIndexPath:indexPath];
   
    cell.labelCollectionCellOrder.text = [self.arr objectAtIndex:indexPath.row];
    cell.imageCollectionCellOrder.image = [UIImage imageNamed:[self.arrImage objectAtIndex:indexPath.row]];
    
    cell.labelCollectionCellOrder.font = [UIFont systemFontOfSize:13*FitW];
    cell.labelCollectionCellOrder.textAlignment = NSTextAlignmentCenter;
    cell.cellMoney.alpha = 0;
    cell.labelCollectionCellOrder.textColor = [UIColor colorWithHexString:@"333333"];
    return cell;
    
}

-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    return CGSizeMake(75 * FitW, 69 * FitH);
}







- (IBAction)dddd:(UIButton *)sender {
    NSLog(@"ffff");

}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
//    switch (indexPath.row) {
//        case 0:
//        {
//            NSLog(@"bbbb");
//        }
//            break;
//            
//        default:
//            break;
//    }
    ReceiveGoodsController *receive = [[ReceiveGoodsController alloc]init];
    id object = [self nextResponder];
    while (![object isKindOfClass:[UIViewController class]]&&object != nil) {
        
        object = [object nextResponder];
    }
    UIViewController *vc = (UIViewController *)object ;
    
    [vc.navigationController pushViewController:receive animated:YES];
    vc.tabBarController.tabBar.hidden = YES;

}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
